﻿using System;
using System.Linq;
using System.Collections.Generic;

namespace HieloCostaAlegre
{
    public class RecordedSales
    {
        private HieloCostaAlegreDataContext db;

        public RecordedSales(DateTime date, Route route)
        {
            EntryDate = date;
            Route = route;
            db = new HieloCostaAlegreDataContext();
        }

        public DateTime EntryDate { get; protected set; }
        public Route Route { get; protected set; }
        
        public ICollection<Product> Products 
        {
            get
            {
                return db.Products
                    .Where(p => p.Active == true)
                    .ToList();
            }
        }

        public ICollection<Business> Businesses
        {
            get
            {
                return db.Businesses
                    .Where(r => r.RouteId == Route.Id)
                    .ToList();
            }
        }
    }
}
